<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title>Document</title>
  <style>
    .menu{display: none;background: #ccc;width:300px;}
  </style>
</head>
<body>
  <input type="button" value="按钮" class="btn">
  <div class="menu">这是一个菜单</div>
</body>
<script>

  $(".btn").onclick =function(eve){
    var e = eve || window.event;
    e.stopPropagation();
    $(".menu").style.display = "block";
  };
  
  document.onclick = function(){
    $(".menu").style.display = "none";
  }

  function $(select){
    return document.querySelector(select);
  }

</script>
</html>